package com.liu.sx.controller;

import com.liu.sx.common.entity.Result;
import com.liu.sx.common.status.CodeEnum;
import com.liu.sx.entity.Menu;
import com.liu.sx.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
      private MenuService menuService;


    @GetMapping
    public Result findAll(){
        List<Menu> menuList =menuService.findAll();

        return new Result(true, CodeEnum.OK.getCode(),"查询成功",menuList);
    }

    @PostMapping
    public Result AddMenu(@RequestBody Menu menu ){
          menuService.addMenu(menu);

        return new Result(true, CodeEnum.OK.getCode(),"添加成功");
    }

}
